<template>
	<view class="main">
		<scroll-view scroll-x="true" class="scroll-box">
			<view class="item-box bg" v-for="(item,index) in goodsList"
				:key="index" @click="chooseItem(item)">
				<image :src="item.icon" :style="'width:'+imgWidth+'rpx;'+'height:'+imgHeight+'rpx;'" mode=""></image>
				<view class="item-name">{{item.name}}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			goodsList: {
				type: Array,
				default: () => []
			},
			imgWidth: {
				type: Number,
				default: 128
			},
			imgHeight: {
				type: Number,
				default: 128
			}
		},
		data() {
			return {}
		},
		mounted() {},
		methods: {
			//点击某个item
			chooseItem(item){
				this.$emit("onClick", item)
			}
		}
	}
</script>

<style>
	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
		display: none;
	}
</style>
<style scoped>
	.main{
		margin:0 4%;
	}
	.scroll-box {
		display: flex;
		white-space: nowrap;
		width: 100%;
		
	}

	.item-box {
		display: inline-block;
		width: 122rpx;
		height: 100%;
		padding: 30rpx 10rpx;
		margin-right: 28rpx;
		border-radius: 12rpx;
		text-align: center;
	}

	.item-name {
		display: table;
		width: 100%;
		font-size: 24rpx;
		line-height: 32rpx;
		font-weight: bold;
		white-space: pre-wrap;
		color: #666;
		margin-top: 8rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		overflow: hidden;
	}
	

	.bg {
		background: linear-gradient(180deg, #FFFCF5 0%, #FBF3E7 100%);
	}
	
</style>